<template>
	<view class="page">
		<view class="card" v-for="(item,index) in list "
			@click="jumpDatail(item.id,item.report_id,item.equipment,item.service_type)" :key='item.report_id'>
			<view class="ful">
				<view class="ful_left">
					状态
				</view>
				<view class="ful_right">
					{{item.status==1?'已完成':'未完成'}}
				</view>
			</view>
			<view class="ful border">
				<view class="ful_left">
					结单时间
				</view>
				<view class="ful_right">
					{{item.statementtime_text||'无'}}
				</view>
			</view>
			<view class="dis">
				<view class="btn">
					详情
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: null,
				page: 1,
				list: [],
				last_page: null
			}
		},
		onLoad(e) {
			this.id = e.id
			// this.getList()
		},
		onShow() {
			if (this.id) {
				this.page = 1
				this.list = []
				this.last_page = null
				this.getList()
			}
		},
		methods: {
			getList() {
				this.$https.post('/warranty/mainten', {
					warranty_id: this.id,
					page: this.page
				}).then(res => {
					this.last_page = res.data.last_page
					this.list = this.list.concat(res.data.data)
				}).catch(err => {
					console.log(err);
				})
			},
			jumpDatail(id, report_id, equipment, service_type) {
				let arr = ['CT', 'DR', 'DSA', '超声', 'MRI', 'DR/F', '小C']
				let res = arr.includes(equipment.pinpai.name)
				if (res) {
					if (service_type != 1) {
						uni.navigateTo({
							url: '../jiedan/jiedan?warranty_id=' + this.id + "&service_id=" + id +
								"&report_id=" + report_id
						})
					} else {
						uni.navigateTo({
							url: '../jiedan/jiedanNew?warranty_id=' + this.id + "&service_id=" + id +
								"&report_id=" + report_id
						})
					}

				} else {
					uni.navigateTo({
						url: '../jiedan/jiedanNew?warranty_id=' + this.id + "&service_id=" + id +
							"&report_id=" + report_id
					})
				}

				// uni.navigateTo({
				// 	url:'../report_detail/report_detail?service_id='+id+"&report_id="+report_id
				// })
			},

		},
		onReachBottom() {
			if (this.page != this.last_page) {
				this.page = this.page + 1
				this.getList()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.dis {
		display: flex;
		justify-content: flex-end;
		padding: 10rpx;
	}

	.btn {
		font-size: 28rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #1A66FF;
		padding: 6rpx 32rpx;
		border-radius: 32rpx;
		opacity: 1;
		border: 2px solid #1A66FF;
	}

	.border {
		border-bottom: 2rpx solid #f7f8fb;
	}

	.page {
		background-color: #f7f8fb;
		min-height: 100vh;
	}

	.ful {
		display: flex;
		justify-content: space-between;
	}

	.ful_left {
		color: #303030;
		padding: 20rpx;
	}

	.ful_right {
		padding: 20rpx;
	}

	.card {
		font-size: smaller;
		color: #999999;

		margin: 30rpx;
		background-color: #fff;
		padding: 10rpx;
		border-radius: 10rpx;
		box-shadow: 10rpx 10rpx 10rpx 10rpx;
	}
</style>